package cn.it.shop.controller.wechat;

import java.util.Map;
import java.util.Random;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.it.shop.controller.BaseController;
import cn.it.shop.util.HttpUtils;
import net.sf.json.JSONObject;

/**
 * ClassName: ActivityController
 * 
 * @Description: 活动控制层
 * @author
 * @date
 */
@Controller
@Scope("prototype")
@RequestMapping("/activity")
public class ActivityController extends BaseController{

	/***
	 * 抽奖 随机数
	 * @param url
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/turnatble")
	public String jssdk(HttpServletRequest request){
		String result = "";
		//获取粉丝id
		Map map = HttpUtils.getRequest(request);
		map.get("openid");
		//生成随机数
		Random rand = new Random(); 
		int resultInt = rand.nextInt(6);//生成1到5的随机数
		
		JSONObject data = new JSONObject();
		if(resultInt == 1  || resultInt == 2 || resultInt == 3){//设置sn码
			data.put("sn",UUID.randomUUID().toString());
			data.put("success",true);
		}else{
			data.put("success",false);
		}
		data.put("error"," ");
		data.put("prizetype", resultInt);
		System.out.println("结果 "+data.toString());
		return data.toString();
	}

	
	
	
	
}
